The present invention relates to a method and apparatus for reading bar-codes.
Barcodes are now well established as a means by which articles (including documents) can be identified. A barcode consists of a background (conventionally white) on which there is an area or a strip consisting of a multiplicity of bars of a contrasting colour (conventionally black), each bar lying transversely across the strip. The widths of the bars and the spaces between them encode information, e.g. a code number identifying the article. The main advantage of using barcodes is that they can be identified automatically.
The output of the barcode reader may be used directly, or may be used in conjunction with other techniques for obtaining information about the article, to verify that information, to be verified by that information, or both.
There are many well established types of barcode readers. One of the simplest kinds is a "light pen" which is manually passed across the barcode (although that requires fairly elaborate clocking circuitry). Another widely used type is a laser reader as used in supermarkets, which includes a continuously scanning laser beam and photocell. When an article with a barcode is passed through the scanning zone, the photocell output is recognized as being that from a barcode.
There are many situations in which barcode readers of such types are entirely satisfactory. These situations generally have three characteristics: first, the original printing of the barcode is generally fairly well controlled, so that the barcode is "clean" and of good contrast; second, the handling of the articles carrying the barcodes is generally fairly well controlled, so that the barcodes are unlikely to become damaged; and third, an operator is normally on hand to enter the identification manually if the barcode reader fails to recognize the barcode.
However, there are many situations where these conditions may not exist. The initial printing of the barcodes may be poorly controlled (e.g. the materials on which they are to be printed may be of highly variable quality); the articles may be subject to severe handling conditions, so that the barcodes may well become dirty, scratched, or otherwise degraded; and it may be expensive or otherwise inconvenient to have an operator available to deal with unrecognizable barcodes.
For these and other reasons, barcode readers have been developed in which the barcode is optically scanned to form an electronic image which is then processed to extract the barcode from it. A barcode reader of this type is described in European Patent Application No. 0 449 634 A. The present invention is concerned with this type of barcode reader.
It may be noted that this type of barcode reader has certain additional advantages. The image can be stored and archived for auditing purposes. Also, the article carrying the barcode may also carry other information, in a form other than the barcode, which can also be extracted from the electronic image. If the article does carry other information which has been read by optical scanning and subsequent processing of an electronic image, then this type of barcode reader can obviously share the scanning mechanism, and requires only additional image processing.
In many situations, the position and orientation of the barcode on the article are both reasonably well defined and controlled. The position and orientation of the barcode in the electronic image will then be similarly defined and controlled. The present invention is concerned with barcode recognition processing means for processing an electronic image in which the barcode occupies such a reasonably well defined position in the image and has a standard orientation.
There can of course be situations in which the position and/or orientation of the barcode is not well defined or controlled, and the position and orientation of the barcode in the electronic image will then be similarly ill-defined and/or ill-controlled. In such situations, techniques are available for performing an initial analysis of the electronic image to locate the barcode and its orientation and to rotate the image (including the barcode) and to shift it, if necessary, so that the barcode occupies a reasonably well defined position in the image and has a standard orientation, i.e. is suitable for the present invention to be used on it. A virtual image rotation can of course be used, by applying a suitable transformation to obtain actual image coordinates from the coordinates used by the barcode recognition processing means.
It is assumed for convenience that the barcode (in the electronic image) occupies a horizontal band, i.e. the bars are vertical. The image will consist of an array of pixels each having a value which corresponds to the brightness or reflectivity of the corresponding point or element of the barcode on the article. The pixel values are measured on a grey scale; we shall assume that pure black (zero reflectance) has a value 0 and pure white (total reflectance) has a value 1, with intermediate shades of grey having values between 0 and 1.
It is also assumed that the barcode is of a type in which the bars extend across the whole width of the band containing the barcode so that the information carried by the barcode is contained exclusively in the widths of the bars and/or their spacing.
The ideal image will consist of a set of geometrically precise bar-shaped areas in which all pixel values are 0 in a field of background pixels with value 1. In practice, however, the "white" pixel values will be somewhat less than 1, the "black" pixel values will be somewhat more than 0, the boundaries around the bands will be fuzzy, and the original barcode and hence also the image may be further degraded in other ways. The barcode reader therefore has to extract, from this degraded image, an accurate representation of the barcode, i.e. it has to extract the information which the barcode represents.
The above-named European Patent Application No. 0 449 634 A proposes various possible ways of achieving this. One way involves simple averaging of the values at corresponding positions in a number of parallel scans across the barcode; a second involves taking the median of those values rather than their average; and a third way involves correlating the various scans and weighting the scans so that those which correlate well with others are given higher weights than those which correlate badly with others.